<template>
  <div class="credit-audit-page">
    <!-- 页面标题 -->
    <div class="page-header">
      <h1 class="page-title">信用分审核</h1>
    </div>

    <!-- 搜索区域 -->
    <div class="search-form">
      <div class="form-row">
        <div class="form-item">
          <label class="form-label">用户ID/姓名</label>
          <input
              type="text"
              class="form-input"
              v-model="searchForm.keyword"
              placeholder="请输入用户ID或姓名"
          >
        </div>
        <div class="form-item">
          <label class="form-label">申请时间</label>
          <div class="date-range">
            <input
                type="date"
                class="form-input"
                v-model="searchForm.startDate"
            >
            <span class="date-separator">至</span>
            <input
                type="date"
                class="form-input"
                v-model="searchForm.endDate"
            >
          </div>
        </div>
        <div class="form-item">
          <label class="form-label">状态</label>
          <select class="form-select" v-model="searchForm.status">
            <option value="">全部</option>
            <option value="pending">待审核</option>
            <option value="approved">已通过</option>
            <option value="rejected">已驳回</option>
          </select>
        </div>
        <div class="form-btn">
          <button class="btn btn-primary" @click="handleSearch">
            <i class="fas fa-search"></i> 搜索
          </button>
          <button class="btn btn-secondary" @click="handleReset">
            <i class="fas fa-redo"></i> 重置
          </button>
        </div>
      </div>
    </div>

    <!-- 信用分审核列表 -->
    <div class="audit-list">
      <div class="list-header">
        <div class="list-title">信用分审核列表</div>
        <div class="list-actions">
          <button class="btn btn-success" @click="handleBatchApprove">
            <i class="fas fa-check"></i> 批量通过
          </button>
          <button class="btn btn-warning" @click="handleBatchReject">
            <i class="fas fa-times"></i> 批量驳回
          </button>
        </div>
      </div>

      <div class="table-container">
        <table class="data-table">
          <thead>
          <tr>
            <th>编号</th>
            <th>用户</th>
            <th>性别</th>
            <th>年龄</th>
            <th>联系方式</th>
            <th>当前信用分</th>
            <th>待审核信用分</th>
            <th>状态</th>
            <th>操作</th>
          </tr>
          </thead>
          <tbody>
          <tr v-for="record in paginatedData" :key="record.id">
            <td>{{ record.id }}</td>
            <td>{{ record.user }}</td>
            <td>{{ record.gender }}</td>
            <td>{{ record.age }}</td>
            <td>{{ record.contact }}</td>
            <td>
              <span class="score-value">{{ record.currentScore }}</span>
            </td>
            <td>
              <span class="score-value">{{ record.pendingScore }}</span>
            </td>
            <td>
                <span class="status-badge" :class="getStatusClass(record.status)">
                  {{ getStatusText(record.status) }}
                </span>
            </td>
            <td>
              <button class="btn btn-text" @click="showDetail(record)">
                <i class="fas fa-eye"></i> 查看详情
              </button>
            </td>
          </tr>
          </tbody>
        </table>

        <!-- 分页控件 -->
        <div class="pagination-container">
          <div class="pagination-info">
            共 {{ pagination.total }} 条记录
          </div>
          <div class="pagination-controls">
            <select class="page-size-select" v-model="pagination.pageSize" @change="handleSizeChange">
              <option value="10">10条/页</option>
              <option value="20">20条/页</option>
              <option value="50">50条/页</option>
            </select>

            <button
                class="pagination-btn"
                :disabled="pagination.currentPage === 1"
                @click="handlePageChange(pagination.currentPage - 1)"
            >
              上一页
            </button>

            <div class="page-numbers">
              <button
                  v-for="page in visiblePages"
                  :key="page"
                  class="page-number"
                  :class="{ active: page === pagination.currentPage }"
                  @click="handlePageChange(page)"
              >
                {{ page }}
              </button>
            </div>

            <button
                class="pagination-btn"
                :disabled="pagination.currentPage === totalPages"
                @click="handlePageChange(pagination.currentPage + 1)"
            >
              下一页
            </button>
          </div>
        </div>
      </div>
    </div>

    <!-- 第一层弹窗：查看详情 -->
    <div v-if="detailVisible" class="modal-overlay" @click.self="hideDetail">
      <div class="modal-content detail-modal" @click.stop>
        <div class="modal-header">
          <h3 class="modal-title">查看详情-信用分审核</h3>
          <button class="modal-close" @click="hideDetail">×</button>
        </div>

        <div class="modal-body">
          <div class="detail-layout">
            <!-- 左侧信息 -->
            <div class="detail-left">
              <!-- 用户信息 -->
              <div class="user-info-section">
                <h4 class="section-title">详情</h4>
                <div class="info-grid">
                  <div class="info-item">
                    <span class="info-label">用户：</span>
                    <span class="info-value">{{ currentDetail.user }}</span>
                  </div>
                  <div class="info-item">
                    <span class="info-label">年龄：</span>
                    <span class="info-value">{{ currentDetail.age }}</span>
                  </div>
                  <div class="info-item">
                    <span class="info-label">联系方式：</span>
                    <span class="info-value">{{ currentDetail.contact }}</span>
                  </div>
                  <div class="info-item">
                    <span class="info-label">账号：</span>
                    <span class="info-value">{{ currentDetail.account }}</span>
                  </div>
                  <div class="info-item">
                    <span class="info-label">性别：</span>
                    <span class="info-value">{{ currentDetail.gender }}</span>
                  </div>
                  <div class="info-item">
                    <span class="info-label">注册时长：</span>
                    <span class="info-value">{{ currentDetail.registerDuration }}</span>
                  </div>
                </div>
              </div>

              <!-- 用户信用分 -->
              <div class="credit-score-section">
                <h4 class="section-title">用户信用分</h4>
                <div class="score-display">
                  <div class="score-item">
                    <div class="score-value">{{ currentDetail.currentScore }}</div>
                    <div class="score-label">当前信用分</div>
                  </div>
                  <div class="score-item">
                    <div class="score-value">{{ currentDetail.pendingScore }}</div>
                    <div class="score-label">待审核信用分</div>
                  </div>
                  <div class="score-item">
                    <div class="score-value">{{ currentDetail.totalScore }}</div>
                    <div class="score-label">总分</div>
                  </div>
                </div>
              </div>

              <!-- 信用分任务列表 -->
              <div class="task-list-section">
                <h4 class="section-title">信用分任务列表</h4>
                <table class="task-table">
                  <thead>
                  <tr>
                    <th>任务名称</th>
                    <th>提交时间</th>
                    <th>状态</th>
                    <th>信用分</th>
                    <th>操作</th>
                  </tr>
                  </thead>
                  <tbody>
                  <tr v-for="task in currentDetail.auditTasks" :key="task.id">
                    <td>{{ task.title }}</td>
                    <td>{{ task.submitTime }}</td>
                    <td>
                        <span class="task-status" :class="getTaskStatusClass(task.status)">
                          {{ getTaskStatusText(task.status) }}
                        </span>
                    </td>
                    <td>
                        <span class="score-change" v-if="task.status === 'approved'">
                          +{{ task.score }}
                        </span>
                      <span v-else-if="task.status === 'pending'">{{ task.score }}</span>
                      <span v-else>0</span>
                    </td>
                    <td>
                      <button
                          class="btn btn-sm btn-text"
                          @click="openTaskAudit(task)"
                          v-if="task.status === 'pending'"
                      >
                        审核
                      </button>
                      <span v-else>已审核</span>
                    </td>
                  </tr>
                  </tbody>
                </table>
              </div>
            </div>
          </div>
        </div>

        <div class="modal-footer">
          <button class="btn btn-secondary" @click="hideDetail">关闭</button>
          <button class="btn btn-primary" @click="submitAudit">提交审核</button>
        </div>
      </div>
    </div>

    <!-- 第二层弹窗：任务审核 -->
    <div v-if="taskAuditVisible" class="modal-overlay task-audit-overlay" @click.self="hideTaskAudit">
      <div class="modal-content task-audit-modal" @click.stop>
        <div class="modal-header">
          <h3 class="modal-title">{{ activeTask ? activeTask.title + '审核' : '任务审核' }}</h3>
          <button class="modal-close" @click="hideTaskAudit">×</button>
        </div>

        <div class="modal-body">
          <div class="task-audit-content">
            <!-- 身份信息审核 -->
            <div v-if="activeTask && activeTask.title === '身份信息'">
              <div class="info-row">
                <span class="info-label">姓名：</span>
                <span class="info-value">{{ currentDetail.user }}</span>
              </div>
              <div class="info-row">
                <span class="info-label">身份证号：</span>
                <span class="info-value">{{ currentDetail.idCard }}</span>
              </div>
            </div>

            <!-- 毕业信息审核 -->
            <div v-if="activeTask && activeTask.title === '毕业信息'">
              <div class="info-row">
                <span class="info-label">毕业学校：</span>
                <span class="info-value">{{ currentDetail.graduateSchool }}</span>
              </div>
              <div class="info-row">
                <span class="info-label">毕业证书：</span>
                <span class="info-value">{{ currentDetail.graduateCert }}</span>
              </div>
            </div>

            <!-- 工作经验审核 -->
            <div v-if="activeTask && activeTask.title === '工作经验'">
              <div class="info-row">
                <span class="info-label">工作年限：</span>
                <span class="info-value">{{ currentDetail.workYears }}</span>
              </div>
              <div class="info-row">
                <span class="info-label">社保记录：</span>
                <span class="info-value">{{ currentDetail.socialSecurity }}</span>
              </div>
            </div>

            <!-- 离职信息审核 -->
            <div v-if="activeTask && activeTask.title === '离职信息'">
              <div class="info-row">
                <span class="info-label">入职时间：</span>
                <span class="info-value">{{ currentDetail.entryTime }}</span>
              </div>
              <div class="info-row">
                <span class="info-label">离职时间：</span>
                <span class="info-value">{{ currentDetail.leaveTime }}</span>
              </div>
              <div class="info-row">
                <span class="info-label">离职原因：</span>
                <span class="info-value">{{ currentDetail.leaveReason }}</span>
              </div>
              <div class="info-row">
                <span class="info-label">证明人电话：</span>
                <span class="info-value">{{ currentDetail.witnessPhone }}</span>
              </div>
            </div>

            <!-- 技能证书审核 -->
            <div v-if="activeTask && activeTask.title === '技能证书'">
              <div class="info-row">
                <span class="info-label">资质证书：</span>
                <span class="info-value">{{ currentDetail.qualificationCert }}</span>
              </div>
              <div class="info-row">
                <span class="info-label">资格证书：</span>
                <span class="info-value">{{ currentDetail.skillCert }}</span>
              </div>
            </div>
          </div>
        </div>

        <div class="modal-footer">
          <button class="btn btn-secondary" @click="hideTaskAudit">取消</button>
          <button class="btn btn-success" @click="showConfirmDialog('approve', activeTask)">
            <i class="fas fa-check"></i> 通过
          </button>
          <button class="btn btn-warning" @click="showConfirmDialog('invalid', activeTask)">
            <i class="fas fa-ban"></i> 无效
          </button>
          <button class="btn btn-danger" @click="showConfirmDialog('reject', activeTask)">
            <i class="fas fa-times"></i> 驳回
          </button>
        </div>
      </div>
    </div>

    <!-- 审核确认弹窗 -->
    <div v-if="confirmDialogVisible" class="modal-overlay confirm-dialog-overlay" @click.self="hideConfirmDialog">
      <div class="modal-content confirm-dialog" @click.stop>
        <div class="modal-header">
          <h3 class="modal-title">审核确认</h3>
          <button class="modal-close" @click="hideConfirmDialog">×</button>
        </div>

        <div class="modal-body">
          <div class="confirm-content">
            <i class="fas fa-exclamation-circle"></i>
            <p>确定要将此任务标记为 <strong>{{ getConfirmActionText(confirmAction) }}</strong> 吗？</p>
            <p class="confirm-detail">任务：{{ confirmTask ? confirmTask.title : '' }}</p>
          </div>
        </div>

        <div class="modal-footer">
          <button class="btn btn-secondary" @click="hideConfirmDialog">取消</button>
          <button class="btn btn-primary" @click="confirmActionHandler">
            确认
          </button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { ref, reactive, computed, onMounted } from 'vue'

export default {
  name: 'CreditAuditPage',
  setup() {
    // 搜索表单数据
    const searchForm = reactive({
      keyword: '',
      startDate: '',
      endDate: '',
      status: ''
    })

    // 分页数据
    const pagination = reactive({
      currentPage: 1,
      pageSize: 10,
      total: 0
    })

    // 弹窗显示状态
    const detailVisible = ref(false)
    const taskAuditVisible = ref(false)
    const confirmDialogVisible = ref(false)
    const currentDetail = ref(null)
    const activeTask = ref(null)
    const confirmAction = ref('')
    const confirmTask = ref(null)

    // 模拟数据 - 确保总分只有10分
    const records = ref([
      {
        id: '489959026',
        user: '张三',
        gender: '男',
        age: 25,
        contact: '12565456963',
        account: '418959526',
        registerDuration: '1个月',
        idCard: '584925199605122568',
        graduateSchool: '东莞理工大学',
        graduateCert: '已上传',
        workYears: '3-5年',
        socialSecurity: '有记录',
        entryTime: '2025.02',
        leaveTime: '2025.06',
        leaveReason: '因个人原因离职',
        witnessPhone: '12564589875',
        qualificationCert: '张三',
        skillCert: '无',
        currentScore: 9,
        pendingScore: 1,
        totalScore: 10,
        status: 'pending',
        auditTasks: [
          {
            id: 1,
            title: '身份信息',
            status: 'pending',
            submitTime: '2025-01-08 20:02',
            score: 1
          },
          {
            id: 2,
            title: '毕业信息',
            status: 'pending',
            submitTime: '2025-01-08 20:02',
            score: 1
          },
          {
            id: 3,
            title: '工作经验',
            status: 'pending',
            submitTime: '2025-01-08 20:02',
            score: 5
          },
          {
            id: 4,
            title: '离职信息',
            status: 'pending',
            submitTime: '2025-01-08 20:02',
            score: 1
          },
          {
            id: 5,
            title: '技能证书',
            status: 'pending',
            submitTime: '2025-01-08 20:02',
            score: 2
          }
        ]
      },
      {
        id: '489959027',
        user: '李四',
        gender: '女',
        age: 29,
        contact: '13800138000',
        account: '418959527',
        registerDuration: '2个月',
        idCard: '584925199605122569',
        graduateSchool: '北京理工大学',
        graduateCert: '已上传',
        workYears: '1-3年',
        socialSecurity: '有记录',
        entryTime: '2025.01',
        leaveTime: '2025.05',
        leaveReason: '合同到期',
        witnessPhone: '13800138001',
        qualificationCert: '李四',
        skillCert: '有',
        currentScore: 8,
        pendingScore: 2,
        totalScore: 10,
        status: 'pending',
        auditTasks: [
          {
            id: 1,
            title: '身份信息',
            status: 'approved',
            submitTime: '2025-01-07 15:30',
            score: 1
          },
          {
            id: 2,
            title: '毕业信息',
            status: 'pending',
            submitTime: '2025-01-07 15:30',
            score: 1
          },
          {
            id: 3,
            title: '工作经验',
            status: 'pending',
            submitTime: '2025-01-07 15:30',
            score: 5
          },
          {
            id: 4,
            title: '离职信息',
            status: 'pending',
            submitTime: '2025-01-07 15:30',
            score: 1
          },
          {
            id: 5,
            title: '技能证书',
            status: 'pending',
            submitTime: '2025-01-07 15:30',
            score: 2
          }
        ]
      },
      {
        id: '489959028',
        user: '王五',
        gender: '男',
        age: 35,
        contact: '13900139000',
        account: '418959528',
        registerDuration: '3个月',
        idCard: '584925199605122570',
        graduateSchool: '清华大学',
        graduateCert: '已上传',
        workYears: '5年以上',
        socialSecurity: '有记录',
        entryTime: '2024.12',
        leaveTime: '2025.04',
        leaveReason: '个人发展',
        witnessPhone: '13900139001',
        qualificationCert: '王五',
        skillCert: '有',
        currentScore: 10,
        pendingScore: 0,
        totalScore: 10,
        status: 'approved',
        auditTasks: [
          {
            id: 1,
            title: '身份信息',
            status: 'approved',
            submitTime: '2025-01-06 10:15',
            score: 1
          },
          {
            id: 2,
            title: '毕业信息',
            status: 'approved',
            submitTime: '2025-01-06 10:15',
            score: 1
          },
          {
            id: 3,
            title: '工作经验',
            status: 'approved',
            submitTime: '2025-01-06 10:15',
            score: 5
          },
          {
            id: 4,
            title: '离职信息',
            status: 'approved',
            submitTime: '2025-01-06 10:15',
            score: 1
          },
          {
            id: 5,
            title: '技能证书',
            status: 'approved',
            submitTime: '2025-01-06 10:15',
            score: 2
          }
        ]
      }
    ])

    // 计算属性
    const filteredData = computed(() => {
      let data = [...records.value]

      // 根据关键词筛选
      if (searchForm.keyword) {
        const keyword = searchForm.keyword.toLowerCase()
        data = data.filter(record =>
            record.user.toLowerCase().includes(keyword) ||
            record.id.includes(keyword)
        )
      }

      // 根据状态筛选
      if (searchForm.status) {
        data = data.filter(record => {
          if (searchForm.status === 'pending') return record.status === 'pending'
          if (searchForm.status === 'approved') return record.status === 'approved'
          if (searchForm.status === 'rejected') return record.status === 'rejected'
          return true
        })
      }

      pagination.total = data.length
      return data
    })

    const paginatedData = computed(() => {
      const startIndex = (pagination.currentPage - 1) * pagination.pageSize
      const endIndex = startIndex + pagination.pageSize
      return filteredData.value.slice(startIndex, endIndex)
    })

    const totalPages = computed(() => {
      return Math.ceil(pagination.total / pagination.pageSize)
    })

    const visiblePages = computed(() => {
      const pages = []
      const maxVisible = 5
      let start = Math.max(1, pagination.currentPage - Math.floor(maxVisible / 2))
      let end = Math.min(totalPages.value, start + maxVisible - 1)

      if (end - start < maxVisible - 1) {
        start = Math.max(1, end - maxVisible + 1)
      }

      for (let i = start; i <= end; i++) {
        pages.push(i)
      }

      return pages
    })

    // 方法
    const getStatusText = (status) => {
      switch (status) {
        case 'pending': return '待审核'
        case 'approved': return '已通过'
        case 'rejected': return '已驳回'
        default: return '未知'
      }
    }

    const getStatusClass = (status) => {
      switch (status) {
        case 'pending': return 'status-pending'
        case 'approved': return 'status-approved'
        case 'rejected': return 'status-rejected'
        default: return ''
      }
    }

    const getTaskStatusText = (status) => {
      switch (status) {
        case 'pending': return '待审核'
        case 'approved': return '已通过'
        case 'invalid': return '无效'
        case 'rejected': return '已驳回'
        default: return '未知'
      }
    }

    const getTaskStatusClass = (status) => {
      switch (status) {
        case 'pending': return 'task-pending'
        case 'approved': return 'task-approved'
        case 'invalid': return 'task-invalid'
        case 'rejected': return 'task-rejected'
        default: return ''
      }
    }

    const getConfirmActionText = (action) => {
      switch (action) {
        case 'approve': return '通过'
        case 'invalid': return '无效'
        case 'reject': return '驳回'
        default: return ''
      }
    }

    const handleSearch = () => {
      pagination.currentPage = 1
    }

    const handleReset = () => {
      searchForm.keyword = ''
      searchForm.startDate = ''
      searchForm.endDate = ''
      searchForm.status = ''
      pagination.currentPage = 1
    }

    const handleBatchApprove = () => {
      if (confirm('确定要通过选中的所有记录吗？')) {
        // 批量通过逻辑
        alert('批量通过成功')
      }
    }

    const handleBatchReject = () => {
      if (confirm('确定要驳回选中的所有记录吗？')) {
        // 批量驳回逻辑
        alert('批量驳回成功')
      }
    }

    const handlePageChange = (page) => {
      if (page < 1 || page > totalPages.value || page === pagination.currentPage) return
      pagination.currentPage = page
    }

    const handleSizeChange = () => {
      pagination.currentPage = 1
    }

    const showDetail = (record) => {
      currentDetail.value = { ...record }
      detailVisible.value = true
      activeTask.value = null
    }

    const hideDetail = () => {
      detailVisible.value = false
      currentDetail.value = null
      activeTask.value = null
    }

    const openTaskAudit = (task) => {
      activeTask.value = task
      // 打开第二层弹窗
      taskAuditVisible.value = true
    }

    const hideTaskAudit = () => {
      taskAuditVisible.value = false
    }

    const showConfirmDialog = (action, task) => {
      confirmAction.value = action
      confirmTask.value = task
      confirmDialogVisible.value = true
    }

    const hideConfirmDialog = () => {
      confirmDialogVisible.value = false
      confirmAction.value = ''
      confirmTask.value = null
    }

    const confirmActionHandler = () => {
      const task = confirmTask.value
      if (!task) return

      switch (confirmAction.value) {
        case 'approve':
          approveTask(task)
          break
        case 'invalid':
          markTaskInvalid(task)
          break
        case 'reject':
          rejectTask(task)
          break
      }

      hideConfirmDialog()
    }

    const approveTask = (task) => {
      task.status = 'approved'
      // 更新当前信用分和待审核信用分
      if (currentDetail.value) {
        currentDetail.value.currentScore += task.score
        currentDetail.value.pendingScore -= task.score
      }
      hideTaskAudit()
    }

    const markTaskInvalid = (task) => {
      task.status = 'invalid'
      // 无效任务不增加信用分
      if (currentDetail.value) {
        currentDetail.value.pendingScore -= task.score
      }
      hideTaskAudit()
    }

    const rejectTask = (task) => {
      task.status = 'rejected'
      // 驳回任务不增加信用分
      if (currentDetail.value) {
        currentDetail.value.pendingScore -= task.score
      }
      hideTaskAudit()
    }

    const submitAudit = () => {
      // 检查是否所有任务都已审核
      const pendingTasks = currentDetail.value.auditTasks.filter(task => task.status === 'pending')
      if (pendingTasks.length > 0) {
        alert('还有未审核的任务，请完成所有审核后再提交')
        return
      }

      // 更新记录状态
      const recordIndex = records.value.findIndex(r => r.id === currentDetail.value.id)
      if (recordIndex !== -1) {
        records.value[recordIndex] = { ...currentDetail.value }

        // 判断整体状态
        const hasRejected = currentDetail.value.auditTasks.some(task => task.status === 'rejected')
        const hasInvalid = currentDetail.value.auditTasks.some(task => task.status === 'invalid')

        if (hasRejected || hasInvalid) {
          records.value[recordIndex].status = 'rejected'
        } else {
          records.value[recordIndex].status = 'approved'
        }
      }

      alert('审核提交成功')
      hideDetail()
    }

    onMounted(() => {
      pagination.total = records.value.length
    })

    return {
      searchForm,
      pagination,
      detailVisible,
      taskAuditVisible,
      confirmDialogVisible,
      currentDetail,
      activeTask,
      confirmAction,
      confirmTask,
      records,
      filteredData,
      paginatedData,
      totalPages,
      visiblePages,
      getStatusText,
      getStatusClass,
      getTaskStatusText,
      getTaskStatusClass,
      getConfirmActionText,
      handleSearch,
      handleReset,
      handleBatchApprove,
      handleBatchReject,
      handlePageChange,
      handleSizeChange,
      showDetail,
      hideDetail,
      openTaskAudit,
      hideTaskAudit,
      showConfirmDialog,
      hideConfirmDialog,
      confirmActionHandler,
      approveTask,
      markTaskInvalid,
      rejectTask,
      submitAudit
    }
  }
}
</script>

<style scoped>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
}

.credit-audit-page {
  padding: 20px;
  background-color: #f5f7fa;
  min-height: 100vh;
}

.page-header {
  margin-bottom: 20px;
}

.page-title {
  font-size: 20px;
  font-weight: 600;
  color: #303133;
}

.search-form {
  background: #fff;
  border-radius: 6px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}

.form-row {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
  align-items: end;
}

.form-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 80px;
}

.form-label {
  font-size: 14px;
  color: #606266;
  font-weight: 500;
}

.form-input, .form-select {
  padding: 8px 12px;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  font-size: 14px;
  transition: border-color 0.3s;
}

.form-input:focus, .form-select:focus {
  outline: none;
  border-color: #409eff;
}

/* 隐藏日期输入框的默认占位符 */
.form-input[type="date"] {
  color: transparent;
}

.date-range {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-separator {
  color: #909399;
  font-size: 14px;
}

.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: #409eff;
  color: #fff;
}

.btn-primary:hover {
  background: #66b1ff;
}

.btn-secondary {
  background: #909399;
  color: #fff;
  margin-left: 10px;
}

.btn-secondary:hover {
  background: #a6a9ad;
}

.btn-success {
  background: #67c23a;
  color: #fff;
}

.btn-success:hover {
  background: #85ce61;
}

.btn-warning {
  background: #e6a23c;
  color: #fff;
}

.btn-warning:hover {
  background: #ebb563;
}

.btn-danger {
  background: #f56c6c;
  color: #fff;
}

.btn-danger:hover {
  background: #f78989;
}

.btn-text {
  background: transparent;
  color: #409eff;
}

.btn-text:hover {
  background: #ecf5ff;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.form-btn {
  display: flex;
  gap: 10px;
  align-self: end;
  margin-bottom: 4px;
}

.audit-list {
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid #ebeef5;
  background: #f5f7fa;
}

.list-title {
  font-size: 16px;
  font-weight: 600;
}

.list-actions {
  display: flex;
  gap: 10px;
}

.table-container {
  padding: 0 20px 20px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th {
  background-color: #f5f7fa;
  color: #606266;
  font-weight: 500;
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid #ebeef5;
}

.data-table td {
  padding: 12px 15px;
  border-bottom: 1px solid #ebeef5;
  color: #606266;
}

.data-table tr:hover {
  background-color: #f5f7fa;
}

.score-value {
  font-weight: 600;
  color: #409eff;
}

.status-badge {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.status-pending {
  background-color: #fdf6ec;
  color: #e6a23c;
}

.status-approved {
  background-color: #f0f9eb;
  color: #67c23a;
}

.status-rejected {
  background-color: #fef0f0;
  color: #f56c6c;
}

.pagination-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 0;
  border-top: 1px solid #ebeef5;
}

.pagination-info {
  font-size: 14px;
  color: #606266;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-size-select {
  padding: 6px 8px;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  font-size: 14px;
}

.pagination-btn {
  padding: 6px 12px;
  margin-right: 10px;
  border: 1px solid #dcdfe6;
  background: #fff;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s;
}

.pagination-btn:hover:not(:disabled) {
  background: #f5f7fa;
}

.pagination-btn:disabled {
  color: #c0c4cc;
  cursor: not-allowed;
}

.page-numbers {
  display: flex;
  gap: 5px;
}

.page-number {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  transition: all 0.3s;
}

.page-number:hover:not(.active) {
  background: #f5f7fa;
}

.page-number.active {
  background: #409eff;
  color: #fff;
  border-color: #409eff;
}

/* 弹窗样式 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  overflow-y: auto;
}

.detail-modal {
  width: 800px;
  max-width: 95vw;
  max-height: 95vh;
}

.task-audit-modal {
  width: 500px;
  max-width: 90vw;
}

.confirm-dialog {
  width: 400px;
  max-width: 90vw;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid #ebeef5;
}

.modal-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #909399;
}

.modal-close:hover {
  color: #606266;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 15px 20px;
  border-top: 1px solid #ebeef5;
}

.detail-layout {
  display: flex;
  gap: 20px;
}

.detail-left {
  flex: 1;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 15px;
  color: #303133;
  padding-bottom: 10px;
  border-bottom: 1px solid #ebeef5;
}

.user-info-section {
  margin-bottom: 20px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
}

.info-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}

.info-label {
  color: #606266;
  font-size: 14px;
}

.info-value {
  color: #303133;
  font-size: 14px;
}

.credit-score-section {
  margin-bottom: 20px;
}

.score-display {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
}

.score-item {
  text-align: center;
  padding: 15px;
  background: #f5f7fa;
  border-radius: 6px;
}

.score-value {
  font-size: 24px;
  font-weight: 600;
  color: #409eff;
  margin-bottom: 5px;
}

.score-label {
  font-size: 14px;
  color: #606266;
}

.task-list-section {
  margin-bottom: 20px;
}

.task-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.task-table th {
  background-color: #f5f7fa;
  color: #606266;
  font-weight: 500;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #ebeef5;
}

.task-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #ebeef5;
  color: #606266;
}

.task-status {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.task-pending {
  background-color: #fdf6ec;
  color: #e6a23c;
}

.task-approved {
  background-color: #f0f9eb;
  color: #67c23a;
}

.task-invalid {
  background-color: #f4f4f5;
  color: #909399;
}

.task-rejected {
  background-color: #fef0f0;
  color: #f56c6c;
}

.score-change {
  color: #67c23a;
  font-weight: 500;
}

.task-audit-content {
  padding: 10px 0;
}

.task-audit-overlay {
  z-index: 1001;
}

.confirm-dialog-overlay {
  z-index: 1002;
}

.confirm-content {
  text-align: center;
  padding: 20px;
}

.confirm-content i {
  font-size: 48px;
  color: #e6a23c;
  margin-bottom: 15px;
}

.confirm-content p {
  margin-bottom: 10px;
  font-size: 16px;
}

.confirm-detail {
  color: #606266;
  font-size: 14px;
}

.info-row {
  margin-bottom: 10px;
  font-size: 14px;
}

.info-label {
  color: #606266;
  font-weight: 500;
}

.info-value {
  color: #303133;
}

@media (max-width: 1024px) {
  .detail-layout {
    flex-direction: column;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .score-display {
    grid-template-columns: 1fr;
  }

  .form-row {
    flex-direction: column;
  }

  .detail-modal {
    width: 95vw;
  }

  .form-btn {
    align-self: stretch;
    margin-bottom: 0;
  }
}
</style>